/**
 *  北京中流科技有限责任公司   版权所有
 */
package cn.com.chinasoa.portlet.dao.toy.action;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import cn.com.chinasoa.portlet.dao.toy.DAOHelper;

import com.x4ee.soa.portal.framework.core.ActionConfig;
import com.x4ee.soa.portal.framework.core.ActionFilter;
import com.x4ee.soa.portal.framework.core.BaseRequestFilter;

/**
 * @author 刘洋(liuyang@chinasoa.com.cn)
 * 2007-7-1 下午11:51:52
 */
public class CreateActionFilter extends BaseRequestFilter implements ActionFilter {
	
	private static String SUCCESS = "success";
	private static String FAILED = "failed";
	public String process(ActionRequest actionRequest, ActionResponse actionResponse, ActionConfig actionConfig) 
		throws PortletException, IOException {
		String name = actionRequest.getParameter("name");
		String tNumber = actionRequest.getParameter("number");
		if((tNumber!=null)&&(name!=null)){
			
		}else{
			return FAILED;
		}
		int number = -1;
		try{
			number = Integer.parseInt(tNumber);
		}catch(Exception e){
			return FAILED;
		}
		if(DAOHelper.addToy(name,number)){
			return SUCCESS;			
		}else{
			return FAILED;
		}
	}

}
